#pragma once
#include <iostream>
#include <memory>

// 产品基类
class IProduct 
{
public:
    virtual void Use() = 0;
    virtual ~IProduct() = default;
};

// 具体产品A
class ConcreteProductA : public IProduct 
{
public:
    void Use() override 
    {
        std::cout << "使用产品A" << std::endl;
    }
};

// 具体产品B
class ConcreteProductB : public IProduct
{
public:
    void Use() override 
    {
        std::cout << "使用产品B" << std::endl;
    }
};

// 工厂基类
class ICreator 
{
public:
    virtual std::unique_ptr<IProduct> CreateProduct() = 0;
    virtual ~ICreator() = default;
};

// 具体工厂A
class ConcreteCreatorA : public ICreator 
{
public:
    std::unique_ptr<IProduct> CreateProduct() override 
    {
        return std::make_unique<ConcreteProductA>();
    }
};

// 具体工厂B
class ConcreteCreatorB : public ICreator 
{
public:
    std::unique_ptr<IProduct> CreateProduct() override 
    {
        return std::make_unique<ConcreteProductB>();
    }
};

